import React, {Component, useEffect, useState} from 'react';
import axios from "axios";

//useEffect(处理副作用)

export default function App() {
    const [list, setlist] = useState([])
    useEffect(() => {
        axios.get("/test.json").then(res => {
            console.log(res.data)
            setlist(res.data.data.films)
        })
    }, [])//传空数组;依赖状态,空数组表示不依赖

    return (
        <div>
            <div>
                {
                    list.map((item, index) =>
                        <div key={item.filmId}>{item.name}</div>
                    )
                }
            </div>
        </div>
    )
}
